/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package merlion.common.entity;

import java.io.Serializable;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import merlion.common.util.Consts;

/**
 *
 * @author Zhang Ying
 */
@Entity
public class JobToDo implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    private String jobType;
    private String title;
    private String content;
    private Integer lastingHour;
    private Integer lastingMinute;
    private Timestamp createdDate;
    private Timestamp deadlineDate;
    private String status;
    private Long relatedId;
    
    public JobToDo(){
        
    }
    
    public boolean isDone(){
        if (status != null & status.equals(Consts.JOB_STATUS_FINISHED)){
            return true;
        }else{
            return false;
        }
    }
    
    public String getFormattedDeadlineDate(){
        SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss dd/MM/yyyy");
        return sdf.format(deadlineDate);
    }
    
    public String getFormattedCreatedDate(){
        SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss dd/MM/yyyy");
        return sdf.format(createdDate);
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public Timestamp getCreatedDate() {
        return createdDate;
    }

    public void setCreatedDate(Timestamp createdDate) {
        this.createdDate = createdDate;
    }

    public Timestamp getDeadlineDate() {
        return deadlineDate;
    }

    public void setDeadlineDate(Timestamp deadlineDate) {
        this.deadlineDate = deadlineDate;
    }

    public String getJobType() {
        return jobType;
    }

    public void setJobType(String jobType) {
        this.jobType = jobType;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public Long getRelatedId() {
        return relatedId;
    }

    public void setRelatedId(Long relatedId) {
        this.relatedId = relatedId;
    }

    public Integer getLastingHour() {
        return lastingHour;
    }

    public void setLastingHour(Integer lastingHour) {
        this.lastingHour = lastingHour;
    }

    public Integer getLastingMinute() {
        return lastingMinute;
    }

    public void setLastingMinute(Integer lastingMinute) {
        this.lastingMinute = lastingMinute;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        if (!(object instanceof JobToDo)) {
            return false;
        }
        JobToDo other = (JobToDo) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "merlion.common.entity.JobToDo[ id=" + id + " ]";
    }
    
}
